.message-item {
    margin-bottom: 24px;
    display: flex;
    width: 100%;
}

.message-item.user {
    justify-content: flex-end;
}

.message-item.assistant {
    justify-content: flex-start;
}

.message-wrapper {
    display: flex;
    align-items: flex-start;
    max-width: 80%;
    gap: 12px;
}

.message-item.user .message-wrapper {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 4px;
}

.avatar-icon {
    font-size: 16px;
}

.user-avatar {
    background: #1890ff;
    color: white;
}

.assistant-avatar {
    background: #52c41a;
    color: white;
}

.message-content-container {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.message-role {
    font-size: 12px;
    font-weight: 600;
    color: #666;
}

.message-time {
    font-size: 11px;
    color: #999;
}

.message-content {
    position: relative;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
    background: white;
    border: 1px solid #e1e5e9;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.message-item.user .message-content {
    background: #1890ff;
    color: white;
    border-color: #1890ff;
}

.message-content.error {
    background: #fff2f0;
    border-color: #ffccc7;
    color: #ff4d4f;
}

.message-content-wrapper {
    position: relative;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.6;
}

/* 模板消息样式 */
.template-message {
    background: linear-gradient(135deg, #f6f9fc 0%, #e9f4ff 100%);
    border: 1px solid #d1ecf1;
    border-radius: 8px;
    padding: 16px;
    margin: 8px 0;
}

.template-message strong {
    color: #0066cc;
    font-weight: 600;
}

.template-message code {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #d63384;
}

.template-message pre {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    margin: 8px 0;
    overflow-x: auto;
}

.template-message pre code {
    background: none;
    border: none;
    padding: 0;
    color: #333;
    font-size: 0.9em;
    line-height: 1.4;
}

/* 黑夜模式下的模板样式 */
body.dark-theme .template-message {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    border-color: #4a5568;
    color: #e2e8f0;
}

body.dark-theme .template-message strong {
    color: #63b3ed;
}

body.dark-theme .template-message code {
    background-color: #2d3748;
    border-color: #4a5568;
    color: #f687b3;
}

body.dark-theme .template-message pre {
    background-color: #2d3748;
    border-color: #4a5568;
}

body.dark-theme .template-message pre code {
    color: #e2e8f0;
}

.copy-button {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 6px;
    cursor: pointer;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message-content:hover .copy-button {
    opacity: 1;
}

.copy-button:hover {
    background: rgba(0, 0, 0, 0.8);
}

.typing-cursor {
    animation: blink 1s infinite;
    font-weight: bold;
    color: #1890ff;
}

.typewriter-cursor {
    animation: blink 1s infinite;
    font-weight: bold;
    color: #1890ff;
    margin-left: 1px;
}

.stream-typewriter {
    display: inline;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.loading-indicator {
    margin-top: 8px;
}

.loading-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #1890ff;
    animation: loading 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loading {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .message-wrapper {
        max-width: 90%;
        gap: 8px;
    }
    
    .message-avatar {
        width: 28px;
        height: 28px;
    }
    
    .avatar-icon {
        font-size: 14px;
    }
    
    .message-content {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .copy-button {
        top: 6px;
        right: 6px;
        padding: 3px 5px;
        font-size: 11px;
    }
}
